<?php
namespace Admin\Event;
use Think\Controller;

class CouponEvent extends Controller
{
    public function index(){
        $ms = M('coupon');
        $res = $ms->select();
        $today = mktime();//即时时间戳
        foreach($res as $k =>$val){
            $end_time = strtotime($res[$k]['end_time']);
            $id = $res[$k]['id'];
            if($end_time<=$today){
//                $ms = M("coupon"); // 实例化User对象
                $data['is_lose'] = 0;
                $res1 = $ms->where("id='$id'")->save($data);
            }else{
                $data['is_lose'] = 1;
                $res1 = $ms->where("id='$id'")->save($data);
            }
        }

        $res = $ms->select();
        return $res;
    }

}